﻿@model XRM.Security.WebUI.Models.UserRegister.UserRegisterModel
@{
    ViewBag.Title = "Выбор пользователя";
    Layout = "~/Views/Shared/_LayoutDialog.cshtml";
}

<style type="text/css">
</style>

<div class="modal-body" style="height:400px;padding-left:20px;">
    @using (Html.BeginForm("AddUserRegisterDialog", "UserRegister", FormMethod.Post, new { id = "dlgAddUserRegisterDialogForm", @class = "form-horizontal form-horizontal-2" }))
    {      
        @Html.AntiForgeryToken()
        const string inputCss = "form-control";
        const string divCss = "col-sm-6";
        
        <div class="form-group">
            @Html.LabelFor(m => m.LastName, new { @class = "control-label required" })
            <div class="@divCss">
                @Html.TextBoxFor(m => m.LastName, new { @class = @inputCss })
                @Html.ValidationMessageFor(m => m.LastName)
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(m => m.FirstName, new { @class = "control-label required" })
            <div class="@divCss">
                @Html.TextBoxFor(m => m.FirstName, new { @class = @inputCss })
                @Html.ValidationMessageFor(m => m.FirstName)
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(m => m.MotherName, new { @class = "control-label" })
            <div class="@divCss">
                @Html.TextBoxFor(m => m.MotherName, new { @class = @inputCss })
                @Html.ValidationMessageFor(m => m.MotherName)
            </div>
        </div>
        
        <div class="form-group">
            @Html.LabelFor(m => m.DepartmentId, new { @class = "control-label" })
            <div class="@divCss">
                @Html.DropDownListFor(m => m.DepartmentId, Model.DepartmentAllList, new { @class = @inputCss })
            </div>
        </div>
        
        <div class="form-group">
            @Html.LabelFor(m => m.DepartmentAddressId, new { @class = "control-label" })
            <div class="@divCss">
                @Html.DropDownListFor(m => m.DepartmentAddressId, Model.DepartmentAddressAllList, new { @class = @inputCss })
            </div>
        </div>
      
    }    
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-primary" id="btnChoise">Выбрать</button>
    <button type="button" class="btn btn-default" data-dismiss="modal">Отмена</button>
</div>

<script type="text/javascript" src="@(Url.Content("~/Scripts/AjaxRequest.js"))"></script>        
<script type="text/javascript">
    $(document).ready(function () {
        $('#DepartmentId').change(function () {
            GetDepartmentAddress();
        });
        $('#btnChoise').on('click', function () { ChoiseUser(); });
    });

    function ChoiseUser() {
        $("#dlgAddUserRegisterDialogForm").submit();
    }
</script>
